float sdEquilateralTriangle(in vec2 p,in float r)
{
    const float k=sqrt(3.);
    p.x=abs(p.x)-r;
    p.y=p.y+r/k;
    if(p.x+k*p.y>0.)p=vec2(p.x-k*p.y,-k*p.x-p.y)/2.;
    p.x-=clamp(p.x,-2.*r,0.);
    return-length(p)*sign(p.y);
}

void mainImage(out vec4 fragColor,in vec2 fragCoord)
{
    vec2 uv=(fragCoord*2.-iResolution.xy)/iResolution.y;
     float d = sdEquilateralTriangle(uv, 0.8);
    
    d = sin(d * 8. + iTime) / 8.;
    d = abs(d);
    
    d = smoothstep(0.0, .5, d);
    
    d = 0.02 / d;
    fragColor=vec4(d,d,d,1.);
}
